home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / message / subcls / dropfile.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-06-26  |  2.4 KB  |  84 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Drop Files On Me"
  4.    ClientHeight    =   2280
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6705
  8.    Height          =   2685
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2280
  12.    ScaleWidth      =   6705
  13.    Top             =   1140
  14.    Width           =   6825
  15.    Begin MsgHook MsgHook 
  16.       Left            =   3735
  17.       Top             =   225
  18.    End
  19.    Begin ListBox List1 
  20.       Height          =   1590
  21.       Left            =   90
  22.       TabIndex        =   0
  23.       Top             =   360
  24.       Width           =   3300
  25.    End
  26.    Begin Label Label1 
  27.       AutoSize        =   -1  'True
  28.       Caption         =   "No Files Dropped Yet"
  29.       Height          =   195
  30.       Left            =   90
  31.       TabIndex        =   1
  32.       Top             =   135
  33.       Width           =   1830
  34.    End
  35. Option Explicit
  36. Sub Form_Load ()
  37.    ' Prepare form to accept dropped files
  38.    Call AcceptDrops((Me.hWnd))
  39.    ' Setup MsgHook control
  40.    MsgHook.HwndHook = Me.hWnd
  41.    MsgHook.Message(WM_DROPFILES) = True
  42. End Sub
  43. Sub Form_Resize ()
  44.    ' Resize Listbox to fit form
  45.    If Me.WindowState <> 1 Then ' not minimized
  46.       List1.Move List1.Left, List1.Top, Me.ScaleWidth - 2 * List1.Left, Me.ScaleHeight - List1.Top - List1.Left
  47.    End If
  48. End Sub
  49. Sub MsgHook_Message (Msg As Integer, wParam As Integer, lParam As Long, Result As Long)
  50.    Dim nFiles As Integer
  51.    Dim Buffer As String
  52.    Dim i As Integer
  53.    Dim nRet As Integer
  54.    ' Always test which message was recieved
  55.    If Msg = WM_DROPFILES Then
  56.       '
  57.       ' Set up buffer to recieve filenames, then
  58.       ' retrieve number of files dropped by passing
  59.       ' &hFFFF as the file number.
  60.       '
  61.       Buffer = Space$(128)
  62.       nFiles = DragQueryFile(wParam, -1&, Buffer, Len(Buffer))
  63.       '
  64.       ' Clear list box and reset label
  65.       '
  66.       List1.Clear
  67.       Label1 = nFiles & " Files Dropped:"
  68.       '
  69.       ' Retrieve the name of each file dropped, and
  70.       ' place in listbox.
  71.       '
  72.       For i = (nFiles - 1) To 0 Step -1
  73.          nRet = DragQueryFile(wParam, i, Buffer, Len(Buffer))
  74.          List1.AddItem Left(Buffer, nRet), 0
  75.       Next i
  76.       List1.ListIndex = 0
  77.       '
  78.       ' Tell system we're done.
  79.       '
  80.       Call DragFinish(wParam)
  81.       Result = 0
  82.    End If
  83. End Sub
  84.